import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Register from '@/components/Register'
import ForgetPwd from '@/components/ForgetPwd'
import Home from '@/components/Home'
import CourseCard from '@/components/CourseCard'
import Course from '@/components/live/CourseClass'
import Live from '@/components/live/Live'
import UserInfo from '@/components/UserInfo'
import CourseDetails from '@/components/CourseDetails'
import Edit from '@/components/CourseEdit'
import Schedule from '@/components/Schedule'
import AddCourse from '@/components/AddCourse'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '*',
      component: Home
    },
    {
      path: '/home',
      redirect: '/index'
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      hidden: true,
      meta: {
        requireAuth: true
      },
      children: [
        {
          path: 'coursecard',
          component: CourseCard,
          alias: '/index',
          meta: {
            requireAuth: true
          }
        }, {
          path: 'course',
          component: Course,
          alias: '/course',
          meta: {
            requireAuth: true,
            equireStatus: true
          }
        }, {
          path: 'live',
          component: Live,
          alias: '/live',
          meta: {
            requireAuth: true
          }
        }, {
          path: 'userinfo',
          alias: '/userinfo',
          component: UserInfo,
          meta: {
            requireAuth: true
          }
        }, {
          path: 'detail',
          alias: '/detail',
          component: CourseDetails,
          meta: {
            requireAuth: true
          }
        }, {
          path: 'edit',
          alias: '/edit',
          component: Edit,
          meta: {
            requireAuth: true,
            requireStatus: true
          }
        }, {
          path: 'addcourse',
          alias: '/addcourse',
          component: AddCourse,
          meta: {
            requireAuth: true
          }
        }, {
          path: 'schedule',
          alias: '/schedule',
          component: Schedule,
          meta: {
            requireAuth: true
          },
          children: [
            {
              path: 'userinfo',
              component: UserInfo,
              meta: {
                requireAuth: true
              }
            },
            {
              path: 'addcourse',
              component: AddCourse,
              meta: {
                requireAuth: true
              }
            }
          ]
        }
      ]
    },
    {
      path: '/register',
      name: 'Register',
      component: Register,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/forgetPwd',
      name: 'ForgetPwd',
      component: ForgetPwd,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/login',
      name: 'Login',
      component: Login,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/',
      name: 'Login',
      redirect: '/login',
      meta: {
        requireAuth: false
      }
    }
  ]
})
